home *** CD-ROM | disk | FTP | other *** search
/ MacGames Sampler / PHT MacGames Bundle.iso / MacSource Folder / Samples from the CD / Editors / emacs / Emacs-1.14b1 / lisp / think-c / think-c.el < prev    next >
Encoding:
Text File  |  1994-04-13  |  3.2 KB  |  89 lines  |  [TEXT/EMAC]

  1. ;;;
  2. ;;; Apple event support for Think C
  3. ;;;
  4.  
  5. (require 'mac-runtime "mac/runtime")
  6.  
  7. (defvar tc:debug-trace nil)
  8. (defvar tc:debug-failures nil)
  9.  
  10. (defun declare-TPM-buffer-variable (name default-value)
  11.   (make-variable-buffer-local name)
  12.   (set-default name default-value))
  13.  
  14. (declare-TPM-buffer-variable 'tc:have-TPM-data nil)
  15. (declare-TPM-buffer-variable 'tc:addressables nil)
  16. (declare-TPM-buffer-variable 'tc:oldSelStart 0)
  17. (declare-TPM-buffer-variable 'tc:oldSelEnd 0)
  18. (declare-TPM-buffer-variable 'tc:oldTextLen 0)
  19. (declare-TPM-buffer-variable 'tc:oldNumLines 0)
  20. (declare-TPM-buffer-variable 'tc:oldLineStart 0)
  21. (declare-TPM-buffer-variable 'tc:oldLineEnd 0)
  22.  
  23. (defconst tc:markers-offset 0)
  24. (defconst tc:breakpoints-offset 4)
  25. (defconst tc:dataviews-offset 8)
  26. (defconst tc:lineOffsets-offset 12)
  27. (defconst tc:bkptIDs-offset 16)
  28. (defconst tc:dtvuIDs-offset 20)
  29. (defconst tc:bkptSizes-offset 24)
  30. (defconst tc:dtvuSizes-offset 28)
  31.  
  32. (defconst tc:sizeof-addressables 32)
  33.  
  34. (defun tc:addressables-get (offset)
  35.   (tc:create-addressables)
  36.   (extract-internal tc:addressables offset 'unsigned-long))
  37.  
  38. (defun tc:addressables-set (offset x)
  39.   (tc:create-addressables)
  40.   (encode-internal tc:addressables offset 'unsigned-long x))
  41.  
  42. (defun tc:markers     () (tc:addressables-get tc:markers-offset))
  43. (defun tc:breakpoints () (tc:addressables-get tc:breakpoints-offset))
  44. (defun tc:dataviews   () (tc:addressables-get tc:dataviews-offset))
  45. (defun tc:lineOffsets () (tc:addressables-get tc:lineOffsets-offset))
  46. (defun tc:bkptIDs     () (tc:addressables-get tc:bkptIDs-offset))
  47. (defun tc:dtvuIDs     () (tc:addressables-get tc:dtvuIDs-offset))
  48. (defun tc:bkptSizes   () (tc:addressables-get tc:bkptSizes-offset))
  49. (defun tc:dtvuSizes   () (tc:addressables-get tc:dtvuSizes-offset))
  50.  
  51. (defun setf-tc:markers     (x) (tc:addressables-set tc:markers-offset x))
  52. (defun setf-tc:breakpoints (x) (tc:addressables-set tc:breakpoints-offset x))
  53. (defun setf-tc:dataviews   (x) (tc:addressables-set tc:dataviews-offset x))
  54. (defun setf-tc:lineOffsets (x) (tc:addressables-set tc:lineOffsets-offset x))
  55. (defun setf-tc:bkptIDs     (x) (tc:addressables-set tc:bkptIDs-offset x))
  56. (defun setf-tc:dtvuIDs     (x) (tc:addressables-set tc:dtvuIDs-offset x))
  57. (defun setf-tc:bkptSizes   (x) (tc:addressables-set tc:bkptSizes-offset x))
  58. (defun setf-tc:dtvuSizes   (x) (tc:addressables-set tc:dtvuSizes-offset x))
  59.  
  60. (defun tc:create-addressables ()
  61.   (if (not tc:addressables)
  62.       (setq tc:addressables (NewPtrClear tc:sizeof-addressables))))
  63.  
  64. ;;; These functions operate on the current buffer.
  65. (defun tc:selStart () (1- (point)))
  66. (defun tc:selEnd () (1- (if (mark) (mark) (point))))
  67. (defun tc:numLines () (count-lines 1 (1+ (buffer-size))))
  68. (defun tc:lineStart () (tc:charPos-to-lineNum (point)))
  69. (defun tc:lineEnd () (tc:charPos-to-lineNum (if (mark) (mark) (point))))
  70. (defun tc:textLen () (buffer-size))
  71.  
  72. ;;; This imitates a lookup in a TextEdit lineStarts array.
  73. (defun tc:charPos-to-lineNum (c)
  74.   (save-excursion
  75.     (goto-char c)
  76.     (let ((i 0))
  77.       (while (search-backward "\n" nil t)
  78.         (setq i (1+ i)))
  79.       i)))
  80.  
  81. (load "think-c/tc-header")
  82. (load "think-c/tc-send")
  83. (load "think-c/tc-exist")
  84. (load "think-c/tc-edit-send")
  85. (load "think-c/tc-reply")
  86. (load "think-c/tc-receive")
  87. (load "think-c/tc-menu")
  88. (load "think-c/think-ref")
  89.